package util;

import net.coobird.thumbnailator.Thumbnails;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * The type Compress img.
 */
public class CompressImg {
    private static String rootPath = "D://finally/picture";

    /**
     * Compress.
     *
     * @param fileName the file name
     */
    public static void compress(String fileName) {
        Thumbnails.Builder<File> fileBuilder = Thumbnails.of(new File(rootPath + "/" + fileName));
        try {
            fileBuilder.scale(1f).outputQuality(0.5f).toOutputStream(new FileOutputStream(rootPath + "/" + fileName));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
